package gold.digger;

import gold.vo.ListNode;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC82 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public ListNode deleteDuplicates(ListNode head) {
            if (null == head || null == head.next) return head;
            int preVal = head.val;
            ListNode cur = head.next;
            while (null != cur && preVal == cur.val) cur = cur.next;
            if (cur == head.next) {
                head.next = deleteDuplicates(cur);
                return head;
            } else {
                return deleteDuplicates(cur);
            }
        }
    }

    public void run() {
        Solution solution = new Solution();
        ListNode head = ListNode.createList("1->2->2");
        System.out.println(solution.deleteDuplicates(head));
    }

    public static void main(String[] args) throws Exception {
        LC82 an = new LC82();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
